const app = getApp();
var wxDraw = require("../../utils/wxdraw.min.js").wxDraw;
var Shape = require("../../utils/wxdraw.min.js").Shape;
// pages/index/message.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    item:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this;
    that.draw(app.globalData.openid);
  },

  draw: function (openid) {
    var that = this;
    var url = app.data.serverUrl + 'draw';
    wx.request({
      url: url,
      data: { 'openid': openid },
      success: function (res) {
        if (res.data.status == true) {
          if(res.data.type=='word') {
            that.setData({
              item: res.data.data,
            })
          } else {
            wx.switchTab({
              url: 'result',
            })
          }
         
        } else {
          wx.showModal({
            title: '提示',
            content: res.data.msg,
            success(res) {
              if (res.confirm) {
                wx.switchTab({
                  url: 'index',
                })
                //console.log('用户点击确定')
              } else if (res.cancel) {
                //console.log('用户点击取消')
              }
            }
          })

        }
      }
    })
  },

  
})